// releasePage/pages/addBusinessHall/operatorList/operatorList.js
import throttle from '../../../../utils/throttle.js';
import Http from '../../../../utils/http.js';
const http = new Http();
const app = getApp();
Page({
    /**
     * 页面的初始数据
     */
    data: {
        companyContent: [],
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.getOperatorList();
    },

    // 确认
    choiceBtn(e) {
        let _that = this;
        let pages = getCurrentPages(); //当前页面栈
        let prevPage = pages[pages.length - 2]; //上一页面
        console.log(e);
        prevPage.setData({
            businessHallValue: e.currentTarget.dataset.name,
            businessHallId: e.currentTarget.dataset.id,
        });
        setTimeout(function () {
            wx.navigateBack({
                delta: 1, // 返回上一级页面。
            });
        }, 300);
    },
    // 获取运营商列表
    getOperatorList() {
        let _that = this;
        let country;
        if (app.globalData.countryBack == '中国') {
            if (app.globalData.addressBack == '香港') {
                country = '中国香港';
            } else if (
                app.globalData.taiwan.includes(app.globalData.addressBack)
            ) {
                country = '中国台湾';
            } else if (app.globalData.addressBack == '澳门') {
                country = '中国澳门';
            } else {
                country = '中国大陆';
            }
        } else {
            country = app.globalData.countryBack;
        }
        let data = {
            authId: app.globalData.authId,
            pageSize: 100,
            pageNo: 1,
            country: country,
        };
        http.getRequest(`cjMap/getCityOperatorList`, data).then((res) => {
            console.log(res);
            for (let i = 0; i < res.data.length; i++) {
                res.data[i].checked = false;
            }
            _that.setData({
                companyContent: res.data,
            });
        });
    },
});
